﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;

namespace ABCNet.Authorization
{
    public class ABCNetAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            // User相关
            context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
            context.CreatePermission(PermissionNames.Pages_Users_Create, L("创建用户"));
            context.CreatePermission(PermissionNames.Pages_Users_CreateAdmin, L("创建管理员"));
            context.CreatePermission(PermissionNames.Pages_Users_Delete, L("删除用户/管理员"));
            context.CreatePermission(PermissionNames.Pages_Users_Update, L("更新用户/管理员"));
            context.CreatePermission(PermissionNames.Pages_Users_Recharge, L("用户充值")); 
            context.CreatePermission(PermissionNames.Pages_Users_Transfer, L("用户转账"));
            context.CreatePermission(PermissionNames.Pages_Users_ChangePassword, L("修改密码"));
            context.CreatePermission(PermissionNames.Pages_Users_ResetPassword, L("重置密码"));

            // Roles相关
            context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
            context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, ABCNetConsts.LocalizationSourceName);
        }
    }
}
